﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using HigLabo.WindowsAzure.RestService.Extensions;

namespace HigLabo.WindowsAzure.RestService.ServiceManagement
{
    public class StorageServiceProperties
    {
        public static readonly String ElementName = "StorageServiceProperties";

        public String Description { get; private set; }        
        public String Location { get; private set; }
        public String AffinityGroup { get; private set; }
        public String Label { get; private set; }
        public StorageServiceStatus Status { get; private set; }

        public StorageServiceProperties(XElement xml)
        {
            if (xml == null)
            {
                throw new ArgumentNullException("xml");
            }
            this.Description = xml.ValueOrEmpty("Description");
            this.Location = xml.ValueOrEmpty("Location");
            this.AffinityGroup = xml.ValueOrEmpty("AffinityGroup");
            var lab = xml.ValueOrEmpty("Label");
            this.Label = Base64Converter.From(lab);
            this.Status = xml.ValueToEnum("Status", StorageServiceStatus.Creating);
        }
    }
}
